home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 21
/
CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso
/
CUCD
/
Programming
/
AsyncIO
/
src
/
PeekAsync.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-06-08
|
588b
|
31 lines
#include "async.h"
_LIBCALL LONG
PeekAsync( _REG( a0 ) AsyncFile *file, _REG( a1 ) APTR buffer, _REG( d0 ) LONG numBytes )
{
#ifdef ASIO_NOEXTERNALS
struct ExecBase *SysBase = file->af_SysBase;
#endif
/* Try to fill a new buffer, if needed */
if( !file->af_BytesLeft )
{
LONG bytes;
if( ( bytes = ReadAsync( file, &bytes, 1 ) ) <= 0 )
{
return( bytes );
}
/* Unread byte */
--file->af_Offset;
++file->af_BytesLeft;
}
/* Copy what we can */
numBytes = MIN( numBytes, file->af_BytesLeft );
CopyMem( file->af_Offset, buffer, numBytes );
return( numBytes );
}